package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/22 22:48
 **/
public class Day20_6_Num112_HasPathSum {
    class Solution {
        public boolean hasPathSum(TreeNode root, int targetSum) {
            if(root == null) return false;
            targetSum -= root.val;
            if(root.left == null && root.right == null){
                if(targetSum == 0) return true;
            }
            return hasPathSum(root.left, targetSum) || hasPathSum(root.right, targetSum);
        }
    }
}